package cn.ycms.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import cn.ycms.bean.Person;
import cn.ycms.dao.bean.PersonDao;
import cn.ycms.service.PersonService;

@Transactional
public class PersonServiceBean implements PersonService {
	@Resource private PersonDao personDao;

	
	
	public int update(Person person){
		try {
			personDao.update(person);
			
			return 1;
		} catch (Exception e) {
			return 0;
		}
	
	
	}
	
	public Person getPerson(String personid){
		return personDao.findById(personid);
	}

	public void delete(String personid){
		personDao.removeById(personid);
	}
	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	@SuppressWarnings("unchecked")
	public List<Person> getPersons(){		
		return personDao.loadAll();
	}
	
	public void save() {
		// TODO Auto-generated method stub
		
	}
	public Person getPerson(int id) {
		// TODO Auto-generated method stub
		return null;
	}
	public void save(Person person) {
		personDao.save(person);
		
	}

	public List<Person> personsliset() {
		// TODO Auto-generated method stub
		return personDao.loadAll();
	}

	public int delete(int id) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	
}
